package router

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"shop_webs/order_web/api/order"
	"shop_webs/order_web/api/pay"
	"shop_webs/order_web/api/shopcart"
	"shop_webs/order_web/middlewares"
)

func InitOrderRouter(Router *gin.RouterGroup) {
	zap.S().Info("配置购物车相关的url")
	ShopcartRouter := Router.Group("shopcarts").Use(middlewares.SetUserId())
	{
		ShopcartRouter.GET("", shopcart.List)          //购物车列表页
		ShopcartRouter.POST("", shopcart.New)          //新建购物车
		ShopcartRouter.PATCH("/:id", shopcart.Update)  //更新购物车
		ShopcartRouter.DELETE("/:id", shopcart.Delete) //删除购物车
	}

	zap.S().Info("配置订单相关的url")
	OrderRouter := Router.Group("orders").Use(middlewares.SetUserId())
	{
		OrderRouter.GET("", order.List)       //订单列表页
		OrderRouter.GET("/:id", order.Detail) //订单商品详细
		OrderRouter.POST("", order.New)       //新建订单
	}
	PayRouter := Router.Group("pay")
	{
		PayRouter.POST("alipay/notify", pay.Notify)
	}
}
